<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* CRM In Activity */
class Crm extends Controller {
	
	function Crm(){
		if(!$this->session->userdata('user_id')){
			redirect($this->config->item('auth'));
		}
        if(!$this->session->userdata('menu2')==1){
			redirect($this->config->item('dashboard'));
		}
        $this->load->model('activities');
	}

	function index(){
		if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin')) ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('empty');
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
            
            $adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif(($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna')) ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('empty');
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
            
            $adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');    
        elseif(($this->session->userdata('user_pos')== ($this->config->item('ta')) || ($this->config->item('ae') == $this->session->userdata('user_pos') ) ) ):
            if(($this->session->userdata('user_group')== $this->config->item('user')) ) :
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";
			elseif(($this->session->userdata('user_group')== $this->config->item('user_dna')) ) :
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";
			endif;	
		
		elseif(($this->config->item('se') == $this->session->userdata('user_pos') )):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";
	
        elseif(($this->session->userdata('user_pos')== $this->config->item('spv')) || ($this->session->userdata('user_pos')==$this->config->item('mgr')) || ($this->session->userdata('user_pos')==$this->config->item('keu') ) ):    
            $add 		         = "";
            $add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
              
			if($this->session->userdata('user_pos')== $this->config->item('spv')):
                $adv_search          = $this->lang->line('adv_search');
				$adv_search_link     = $this->config->item('actv_search');
				$adv_search_active   = $this->config->item('empty');
            else:
                $adv_search          = "";
                $adv_search_link     = ""; 
                $adv_search_active   = "";
            endif;    
        else:
            $add 		         = "";
            $add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
              
			$adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;
        
        if($this->session->userdata('user_pos')== $this->config->item('ta')):
                    $access = $this->config->item('ta');
        elseif($this->session->userdata('user_pos')== $this->config->item('se')):
                    $access = $this->config->item('se');
        else:
                    $access = "";               
        endif;      
		
		$data = array(
                        'title'		=>	$this->lang->line('activity'),
                        'table'		=>	array(
												'activity'			=>	$this->activities->getAll(),
											 ),
                        'access'    =>  $access,                                   
						'content'	=> 	'list',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('active'),
												'job_active'		=>	$this->config->item('empty'),
												'user_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('empty'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_agenda'),
												'tab1_link'			=>	$this->config->item('activity'),
												'tab1_active'		=>	$this->config->item('active'),
                                                'tab2'				=>	$add,
												'tab2_link'			=>	$add_link,
												'tab2_active'		=>	$add_active,
                                                'tab3'				=>	$list_target,
                                                'tab3_link'			=>	$list_target_link,
												'tab3_active'		=>	$list_target_active,
                                                'tab4'				=>	'',
												'tab4_link'			=>	$new_target_link,
												'tab4_active'		=>	$new_target_active,
                                                'tab5'				=>	$this->lang->line('actv_daily'),
                                                'tab5_link'			=>	$this->config->item('actv_daily'),
												'tab5_active'		=>	$this->config->item('empty'),
												'tab6'				=>	"",
                                                'tab6_link'			=>	"",
												'tab6_active'		=>	$this->config->item('empty'),
												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                'tab7_link'			=>	$this->config->item('actv_monthly'),
												'tab7_active'		=>	$this->config->item('empty'),
												'tab8'				=>	$adv_search,
                                                'tab8_link'			=>	$adv_search_link,
												'tab8_active'		=>	$adv_search_active,
											 )				
					 );
		$this->load->vars($data);
		$this->load->theme('default');
	}
    
    function viewactv($id){
	   /* if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
        if(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ( $this->config->item('se') == $this->session->userdata('user_pos') ) || ($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin') )  ):
            
            if(!$id){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }
        
        if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = "";
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif( ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');    
        elseif(($this->session->userdata('user_pos')== $this->config->item('ta'))  ):
            if( ($this->session->userdata('user_group')== $this->config->item('user')) ): 
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			endif;		
        
		elseif(($this->config->item('se') == $this->session->userdata('user_pos') )):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
        else:
            $add 		         = "";
           	$add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = ""; 
             
		    $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;      
               
    		$data = array(
    						'title'		=>	$this->lang->line('view').' '.$id,
    						'table'		=>	array(
                                                    'value'				=>	$this->activities->getData($id),
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'customers'         =>  $this->activities->getCustomer(),
                                                    'type'			    =>	$this->activities->getType(),
    											 ),
                            'form'      =>  array('action'=>$this->config->item('actv_update')),                     
    						'content'	=> 	'view',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
                            'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$this->lang->line('add'),
    												'tab2_link'			=>	$this->config->item('actv_add'),
    												'tab2_active'		=>	$this->config->item('empty'),
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	$this->config->item('empty'),
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	$this->lang->line('actv_weekly'),
                                                    'tab6_link'			=>	$this->config->item('actv_weekly'),
    												'tab6_active'		=>	$this->config->item('empty'),
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$this->lang->line('view'),
                                                    'tab3_link'			=>	$this->config->item('actv_view').$id,
    												'tab3_active'		=>	$this->config->item('active'),
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
    												'tab8_active'		=>	$adv_search_active
    											 )	                     		
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
            
        else:    
            redirect($this->config->item('activity'));
        endif;    
	}
    
    function daily(){
        if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = "";
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif( ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('empty');
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');    
        elseif(($this->session->userdata('user_pos')== ($this->config->item('ta'))) || ($this->session->userdata('user_pos')== ($this->config->item('ae'))) || ($this->config->item('se') == $this->session->userdata('user_pos') )) :
            if( ($this->session->userdata('user_group')== $this->config->item('user'))): 
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna'))): 
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			endif;			
				
        else:
            $add 		         = "";
           	$add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = ""; 
             
		    $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;  
		
        if($this->session->userdata('user_pos')== $this->config->item('ta')):
                    $access = $this->config->item('ta');
        elseif($this->session->userdata('user_pos')== $this->config->item('se')):
                    $access = $this->config->item('se');
        else:
                    $access = "";               
        endif;
        
		$data = array(
                        'title'		=>	$this->lang->line('actv_daily'),
                        'table'		=>	array(
												'activity'			=>	$this->activities->getPeriode('daily'),
                                                'activity_all'		=>	$this->activities->getAll(),
											 ),
                        'access'    =>  $access,             
						'content'	=> 	'list',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('active'),
												'job_active'		=>	$this->config->item('empty'),
												'user_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('empty'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_agenda'),
												'tab1_link'			=>	$this->config->item('activity'),
												'tab1_active'		=>	$this->config->item('empty'),
                                                'tab2'				=>	$add,
												'tab2_link'			=>	$add_link,
												'tab2_active'		=>	$add_active,
                                                'tab4'				=>	'',
												'tab4_link'			=>	'',
												'tab4_active'		=>	'',
                                                'tab5'				=>	$this->lang->line('actv_daily'),
                                                'tab5_link'			=>	$this->config->item('actv_daily'),
												'tab5_active'		=>	$this->config->item('active'),
												'tab6'				=>	"",
                                                'tab6_link'			=>	"",
												'tab6_active'		=>	"",
												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                'tab7_link'			=>	$this->config->item('actv_monthly'),
												'tab7_active'		=>	$this->config->item('empty'),
												'tab3'				=>	$list_target,
                                                'tab3_link'			=>	$list_target_link,
												'tab3_active'		=>	$list_target_active,
												'tab8'				=>	$adv_search,
                                                'tab8_link'			=>	$adv_search_link,
												'tab8_active'		=>	$adv_search_active,
									
											 )				
					 );
		$this->load->vars($data);
		$this->load->theme('default');
	}
    
    function weeklyreport(){
        if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = "";
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif( ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('active');
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');    
        elseif( ($this->session->userdata('user_pos')== ($this->config->item('ae'))) || ($this->session->userdata('user_pos')== ($this->config->item('ta')) || ($this->config->item('se') == $this->session->userdata('user_pos')  ) ) ):
            if( ($this->session->userdata('user_group')== $this->config->item('user'))):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";  
			elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna')) || ($this->session->userdata('user_group')== $this->config->item('admin_dna')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('active');;
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";  
			endif;	
                 			
        else:
            $add 		         = "";
           	$add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = ""; 
             
		    $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;  
		
        if($this->session->userdata('user_pos')== $this->config->item('ta')):
                    $access = $this->config->item('ta');
        elseif($this->session->userdata('user_pos')== $this->config->item('se')):
                    $access = $this->config->item('se');
		elseif($this->session->userdata('user_pos')== $this->config->item('ae')):
                    $access = $this->config->item('ae');			
        else:
                    $access = "";               
        endif;
             
		$data = array(
                        'title'		=>	$this->lang->line('actv_weekly'),
                        'table'		=>	array(
												'activity'			=>	$this->activities->getPeriode('weekly'),
                                                'activity_all'		=>	$this->activities->getAll(),
											 ),
                        'access'    =>  $access,             
						'content'	=> 	'list',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('active'),
												'job_active'		=>	$this->config->item('empty'),
												'user_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('empty'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_agenda'),
												'tab1_link'			=>	$this->config->item('activity'),
												'tab1_active'		=>	$this->config->item('empty'),
                                                'tab2'				=>	$add,
												'tab2_link'			=>	$add_link,
												'tab2_active'		=>	$add_active,
                                                'tab4'				=>	'',
												'tab4_link'			=>	'',
												'tab4_active'		=>	'',
                                                'tab5'				=>	$this->lang->line('actv_daily'),
                                                'tab5_link'			=>	$this->config->item('actv_daily'),
												'tab5_active'		=>	$this->config->item('empty'),
												'tab6'				=>	"",
                                                'tab6_link'			=>	"",
												'tab6_active'		=>	"",
												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                'tab7_link'			=>	$this->config->item('actv_monthly'),
												'tab7_active'		=>	$this->config->item('empty'),
												'tab3'				=>	$list_target,
                                                'tab3_link'			=>	$list_target_link,
												'tab3_active'		=>	$list_target_active,
												'tab8'				=>	$adv_search,
                                                'tab8_link'			=>	$adv_search_link,
												'tab8_active'		=>	$adv_search_active,
											 )				
					 );
		$this->load->vars($data);
		$this->load->theme('default');
	}
    
    function monthly(){
        if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin')) ) :
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('empty');
        elseif( ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna')) ) :
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('empty');    
        elseif(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae'))  ) :
            if( ($this->session->userdata('user_group')== $this->config->item('user')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
            elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
            endif;			
        elseif($this->config->item('se') == $this->session->userdata('user_pos')):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
		else:
            $add 		         = "";
            $add_link 	         = "";
            $add_active	         = "";
            
            $adv_search          = "";  
            $adv_search_link     = ""; 
            $adv_search_active   = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";
            
        endif;
        
        if($this->session->userdata('user_pos')== $this->config->item('ta')):
                    $access = $this->config->item('ta');
        elseif($this->session->userdata('user_pos')== $this->config->item('se')):
                    $access = $this->config->item('se');
        else:
                    $access = "";               
        endif;
             
		$data = array(
                        'title'		=>	$this->lang->line('actv_monthly'),
                        'table'		=>	array(
												'activity'			=>	$this->activities->getPeriode('monthly'),
                                                'activity_all'		=>	$this->activities->getAll()
                                                
											 ),
                        'access'    =>  $access,             
						'content'	=> 	'list',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('active'),
												'job_active'		=>	$this->config->item('empty'),
												'user_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('empty'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_agenda'),
												'tab1_link'			=>	$this->config->item('activity'),
												'tab1_active'		=>	$this->config->item('empty'),
                                                'tab2'				=>	$add,
												'tab2_link'			=>	$add_link,
												'tab2_active'		=>	$add_active,
                                                'tab4'				=>	'',
												'tab4_link'			=>	'',
												'tab4_active'		=>	'',
                                                'tab5'				=>	$this->lang->line('actv_daily'),
                                                'tab5_link'			=>	$this->config->item('actv_daily'),
												'tab5_active'		=>	$this->config->item('empty'),
												'tab6'				=>	"",
                                                'tab6_link'			=>	"",
												'tab6_active'		=>	"",
												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                'tab7_link'			=>	$this->config->item('actv_monthly'),
												'tab7_active'		=>	$this->config->item('active'),
												'tab3'				=>	$list_target,
                                                'tab3_link'			=>	$list_target_link,
												'tab3_active'		=>	$list_target_active,
												'tab8'				=>	$adv_search,
                                                'tab8_link'			=>	$adv_search_link,
												'tab8_active'		=>	$adv_search_active,
												'tab9'				=>	'',
                                                'tab9_link'			=>	$this->config->item('edit_user'),
												'tab9_active'		=>	$this->config->item('empty'),
											 )				
					 );
		$this->load->vars($data);
		$this->load->theme('default');
	}
    
    function addnew(){
	    /*if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
        if(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ( $this->config->item('se') == $this->session->userdata('user_pos') ) || ($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('user_dna') ) ):
            
            if($this->session->userdata('user_group')== $this->config->item('admin')):
                $add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('active');
                
                $list_target 		 = "";
                $list_target_link 	 = "";
                $list_target_active  = "";
                
                $adv_search          = $this->lang->line('adv_search');
                $adv_search_link     = $this->config->item('actv_search');
                $adv_search_active   = $this->config->item('empty');
            elseif($this->session->userdata('user_group')== $this->config->item('admin_dna')):
                $add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('active');
                
                $list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
                
                $adv_search          = $this->lang->line('adv_search');
                $adv_search_link     = $this->config->item('actv_search');
                $adv_search_active   = $this->config->item('empty');    
            elseif( ($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae'))  ):
            if( ($this->session->userdata('user_group')== $this->config->item('user')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('active');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
            elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna')) ):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('active');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = $this->config->item('empty');
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
            endif;
   
			elseif($this->config->item('se') == $this->session->userdata('user_pos')):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('active');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			else:
                $add 		         = "";
                $add_link 	         = "";
                $add_active	         = "";
                
                $list_target 		 = "";
                $list_target_link 	 = "";
                $list_target_active  = "";
                
                $adv_search          = "";  
                $adv_search_link     = ""; 
                $adv_search_active   = "";
            endif;     
               
    		$data = array(
    						'title'		=>	$this->lang->line('add'),
    						'table'		=>	array(
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'customers'         =>  $this->activities->getCustomer(),
                                                    'type'			    =>	$this->activities->getType(),
                                                    'user_dna'          =>  $this->activities->getUserDNA(),
                                                    'value'             => ""
    											 ),
                            'form'      =>  array('action'=>$this->config->item('actv_save')),                      
    						'content'	=> 	'form',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
    						'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$add,
    												'tab2_link'			=>	$add_link,
    												'tab2_active'		=>	$add_active,
                                                    'tab3'				=>	$list_target,
                                                    'tab3_link'			=>	$list_target_link,
    												'tab3_active'		=>	$list_target_active,
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	'',
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	"" ,
                                                    'tab6_link'			=>	"" ,
    												'tab6_active'		=>	"",
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
    												'tab8_active'		=>	$adv_search_active
    											 )			
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
        else:
            redirect($this->config->item('activity'));    
        endif;        
	}
    
    function saveactv(){
        /*if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
        if(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ( $this->config->item('se') == $this->session->userdata('user_pos') ) || ($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna') )  ):
            
            if($this->input->post('save')):
                $val=count($this->activities->getCek());
                if($val < 1):
                    $this->activities->getSave();
                    $this->session->set_flashdata('message','<span class="message success"><strong>Success </strong>message - '.$this->lang->line('m_save').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                else:
                    $this->session->set_flashdata('message','<span class="message error"><strong>Success</strong>message - '.$this->lang->line('m_duplicate').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                endif;
            endif;
        else:
            redirect($this->config->item('activity'));     
        endif;  
    }
    
     function editactv($id){
	   /* if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
        if(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ( $this->config->item('se') == $this->session->userdata('user_pos') ) || ($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna') )  ):
            
            if(!$id){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }
        
        if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))  ):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
        
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = "";
            
            $new_target 		 = $this->lang->line('new_target');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active  = "";
        
			$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== ($this->config->item('ae'))  ) ):
            if( ($this->session->userdata('user_group')== $this->config->item('user'))):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";   
			elseif( ($this->session->userdata('user_group')== $this->config->item('user_dna'))):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = $this->lang->line('actv_weekly');
				$list_target_link 	 = $this->config->item('actv_weekly');
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = ""; 
			endif;		
        
		elseif(($this->config->item('se') == $this->session->userdata('user_pos')  )):
				$add 		         = $this->lang->line('add');
				$add_link 	         = $this->config->item('actv_add');
				$add_active          = $this->config->item('empty');
				
				$list_target 		 = "";
				$list_target_link 	 = "";
				$list_target_active  = "";
				
				$new_target 		 = "";
				$new_target_link 	 = "";
				$new_target_active   = "";
				
				$adv_search          = "";
				$adv_search_link     = "";
				$adv_search_active   = "";   
		else:
            $add 		         = "";
           	$add_link 	         = "";
            $add_active	         = "";
            
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = ""; 
             
		    $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;      
               
    		$data = array(
    						'title'		=>	$this->lang->line('edit').' '.$id,
    						'table'		=>	array(
                                                    'value'				=>	$this->activities->getData($id),
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'customers'         =>  $this->activities->getCustomer(),
                                                    'user_dna'          =>  $this->activities->getUserDNA(),
                                                    'type'			    =>	$this->activities->getType(),
    											 ),
                            'form'      =>  array('action'=>$this->config->item('actv_update')),                     
    						'content'	=> 	'form',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
                            'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$this->lang->line('add'),
    												'tab2_link'			=>	$this->config->item('actv_add'),
    												'tab2_active'		=>	$this->config->item('empty'),
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	$this->config->item('empty'),
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	$this->lang->line('actv_weekly'),
                                                    'tab6_link'			=>	$this->config->item('actv_weekly'),
    												'tab6_active'		=>	$this->config->item('empty'),
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$this->lang->line('edit'),
                                                    'tab3_link'			=>	$this->config->item('actv_edit').$id,
    												'tab3_active'		=>	$this->config->item('active'),
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
    												'tab8_active'		=>	$adv_search_active,
    												'tab9'				=>	'',
                                                    'tab9_link'			=>	$this->config->item('edit_user'),
    												'tab9_active'		=>	$this->config->item('empty'),
    											 )	                     		
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
            
        else:    
            redirect($this->config->item('activity'));
        endif;    
	}
    
     function updateactv(){
        /*if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
		
		
        if(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ( $this->config->item('se') == $this->session->userdata('user_pos') ) || ($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin') )  || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna') ) ):
              
            if($this->input->post('save')):
                    $this->activities->getUpdate();
                    $this->session->set_flashdata('message','<span class="message success"><strong>Success</strong>message - '.$this->lang->line('m_update').'  </span>');
                    redirect($this->input->server('HTTP_REFERER')); 
            endif;
        else:
            redirect($this->config->item('activity'));
        endif;    
    }
    
    function deleteactv($id){
		
		
        /*if($this->session->userdata('user_group')!= $this->config->item('admin') ){
            redirect($this->config->item('activity'));
        }*/
        $this->activities->getRemove($id);
        $this->session->set_flashdata('message','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_delete').'  </span>');
        redirect($this->input->server('HTTP_REFERER'));
        
    }
    
    
    function saveactvtype(){
		if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		
        if(($this->session->userdata('user_group')== $this->config->item('admin') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) ):
            
            if($this->input->post('save')):
                $val=count($this->activities->getTypeCek());
                if($val<1):
                    $this->activities->getTypeSave();
                    $this->session->set_flashdata('message2','<span class="message success"><strong>Success</strong>message - '.$this->lang->line('m_save').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                else:
                    $this->session->set_flashdata('message2','<span class="message error"><strong>Error </strong>message - '.$this->lang->line('m_duplicate').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                endif;
            endif;
        else:
            redirect($this->config->item('activity'));
        
        endif;
    }
    
    function updateactvtype(){
		if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		
        if(($this->session->userdata('user_group')== $this->config->item('admin') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) ):
            
            if($this->input->post('save')):
                    $this->activities->getTypeUpdate();
                    $this->session->set_flashdata('message2','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_update').'  </span>');                     
                 
            elseif($this->input->post('delete')):  
                    $this->activities->getTypeRemove();    
                    $this->session->set_flashdata('message2','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_delete').'  </span>');     
            endif;
            redirect($this->input->server('HTTP_REFERER')); 
        else:
            redirect($this->config->item('activity'));
        endif; 
    } 
    
    function searchactv(){
		if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		
	    if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_pos')== $this->config->item('spv') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna') ) ):
         
           
    		if( ($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin')) ):
                $add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('empty');
                
                $list_target 		 = $this->lang->line('actv_weekly');
                $list_target_link 	 = $this->config->item('actv_weekly');
                $list_target_active  = $this->config->item('empty');
                
                $adv_search          = $this->lang->line('adv_search');
                $adv_search_link     = $this->config->item('actv_search');
                $adv_search_active   = $this->config->item('active');
                
            elseif( ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin_dna')) ):
                $add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('empty');
                
                $list_target 		 = $this->lang->line('actv_weekly');
                $list_target_link 	 = $this->config->item('actv_weekly');
                $list_target_active  = $this->config->item('empty');
                
                $adv_search          = $this->lang->line('adv_search');
                $adv_search_link     = $this->config->item('actv_search');
                $adv_search_active   = $this->config->item('active');     
               
            else:
                $add 		         = "";
                $add_link 	         = "";
                $add_active	         = "";
                
                $list_target 		 = "";
                $list_target_link 	 = "";
                $list_target_active  = "";
                
                $adv_search          = "";  
                $adv_search_link     = ""; 
                $adv_search_active   = "";
            endif;
            
            if($this->session->userdata('user_pos')== $this->config->item('ta')):
                        $access = $this->config->item('ta');
            elseif($this->session->userdata('user_pos')== $this->config->item('se')):
                        $access = $this->config->item('se');
            else:
                        $access = "";               
            endif;        
    		
    		$data = array(
                            'title'		=>	$this->lang->line('adv_search'),
                            'table'		=>	array(
    												'activity'			=>	$this->activities->getSearch(),
               	                                    'type'			    =>	$this->activities->getType(),
                                                    'users'			    =>	$this->activities->getUsers()
    											 ),
                            'form'      =>  array('action'=>$this->config->item('actv_search')),  
                            'access'    =>  $access,             
    						'content'	=> 	'list',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
    						'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$add,
    												'tab2_link'			=>	$add_link,
    												'tab2_active'		=>	$add_active,
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	'',
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	"",
                                                    'tab6_link'			=>	"",
    												'tab6_active'		=>	"",
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$list_target,
                                                    'tab3_link'			=>	$list_target_link,
    												'tab3_active'		=>	$list_target_active,
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
    												'tab8_active'		=>	$adv_search_active,
    												'tab9'				=>	'',
                                                    'tab9_link'			=>	$this->config->item('adv_search'),
    												'tab9_active'		=>	$this->config->item('empty'),
    											 )				
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
        else:
            redirect($this->config->item('activity'));
        endif;    
	}
	
	function report($id=''){
        $file_type="xls";
        $file_name="activity_report.xls";
        header("Content-Type: application/$file_type");
        header("Content-Disposition: attachment; filename=$file_name");
        header("Pragma: no-cache");
        header("Expires: 0"); 
        set_time_limit(3360);   
		$objPHPExcel = new PHPExcel();
        $objPHPExcel->getProperties()->setTitle("title")
                    ->setDescription("description");
		$objPHPExcel->setActiveSheetIndex(0);
        $styleArray = array( 'borders' => array( 'allborders' => array(
                             'style' => Style_Border::BORDER_THIN )));
        $fill = array(
      			'type'       => Style_Fill::FILL_SOLID,
      			'rotation'   => 0,
      			'startcolor' => array(
      				'rgb' => 'CCCCCC'
      			),
      			'endcolor'   => array(
      				'argb' => 'CCCCCC'
      			)
      		);   
        
        $row=1;
        $col=0;
       
        
        /* NO */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row,'No');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setWidth(5);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col,$row)->getFill()->applyFromArray($fill);
        /* NO */
        
        /* Tanggal */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1,$row,'Tanggal');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+1)->setWidth(12);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+1,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+1,$row)->getFill()->applyFromArray($fill);
        /* Tanggal */
          
        /* Waktu */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2,$row,'Waktu');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+2)->setWidth(10);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+2,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+2,$row)->getFill()->applyFromArray($fill);
		/* Waktu */
        
        /* Customer Name */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3,$row,'Customer Name');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+3)->setWidth(25);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+3,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+3,$row)->getFill()->applyFromArray($fill);
        /* Customer Name */
        
        /* PIC */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4,$row,'PIC');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+4)->setWidth(25);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+4,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+4,$row)->getFill()->applyFromArray($fill);
        /* PIC */
        
        /* Telepon */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5,$row,'Telepon');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+5)->setWidth(15);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+5,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+5,$row)->getFill()->applyFromArray($fill);
        /* Telepon */
        
        /* Type */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+6,$row,'Type');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+6)->setWidth(15);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+6,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+6,$row)->getFill()->applyFromArray($fill);
        /* Type */
        
        /* Rev Position */
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+7,$row,'Rev');
        $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+7)->setWidth(15);
        $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+7,$row)->applyFromArray($styleArray);
		$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+7,$row)->getFill()->applyFromArray($fill);
        /* Rev Position */
        
        
        //$sql =" SELECT *,a.id ";
        //$sql.=" FROM activity_transaction at ";
        //$sql.=" LEFT JOIN activity a  ON a.id=at.activity_id ";
        //$sql.=" WHERE at.customer_id=".$id;
        //$q=$this->db->query($sql);
        $data=$this->activities->getSearch();
		//$data=$q->result_array();
        $row=$row+1;
		$no=1;
        foreach($data as $rec):
        /* No */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row,$no);
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col,$row)->applyFromArray($styleArray);
        /* No */
        
        /* Tanggal */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1,$row,$rec['activity_date']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+1,$row)->applyFromArray($styleArray);
        /* Tanggal */
        
        /* Waktu */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2,$row,$rec['activity_time']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+2,$row)->applyFromArray($styleArray);
        /* Waktu */
        
        /* Customer */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3,$row,$rec['customer_name']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+3,$row)->applyFromArray($styleArray);
        /* Customer */
        
        /* Customer PIC */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4,$row,$rec['pic']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+4,$row)->applyFromArray($styleArray);
        /* Customer PIC */
		
		/* Customer PIC */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5,$row,$rec['tlp']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+5,$row)->applyFromArray($styleArray);
        /* Customer PIC */
		
		/* Customer PIC */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+6,$row,$rec['activity_type']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+6,$row)->applyFromArray($styleArray);
        /* Customer PIC */
		
		/* Customer PIC */
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+7,$row,$rec['rev']);
		    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col+7,$row)->applyFromArray($styleArray);
        /* Customer PIC */
        
        $row=$row+1;
		$no++;
        endforeach;
        
        // Save it as an excel 2003 file
		$objWriter = IOFactory::createWriter($objPHPExcel, "Excel5");
		$file=$file_name.'.'.$file_type;
		$path='crm-media/data/activity/';
        $objWriter->save($path.$file);
		redirect($path.$file,301);
    }
    
    function weekly(){
	   /*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
	   endif;*/
		
       if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') )  ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta') ) || ($this->session->userdata('user_pos')== $this->config->item('se') ) || ($this->session->userdata('user_pos')== $this->config->item('ae') ) ):
          
		if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('active');
            
            $new_target 		 = $this->lang->line('new_weekly');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active   = $this->config->item('empty');
            
           	$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae')) || ($this->session->userdata('user_pos')== $this->config->item('se'))):
			$add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('active');
            
            $new_target 		 = $this->lang->line('new_weekly');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active   = $this->config->item('empty');
            
           	$adv_search          = "";
            $adv_search_link     = "";
            $adv_search_active   = "";
		else:
            $add 		         = "";
            $add_link 	         = "";
            $add_active	         = "";
        
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";  
			
            $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;      
		
		$data = array(
                        'title'		=>	$this->lang->line('actv_weekly'),
                        'table'		=>	array(
												'activity'			=>	$this->activities->getAll(),
                                                'target'            =>  $this->activities->getAllTarget(),
                                                'actv_week'         =>  $this->activities->getActivityMonth(),
                                                'type'			    =>	$this->activities->getType()
											 ),
                                     
						'content'	=> 	'list_target',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('active'),
												'job_active'		=>	$this->config->item('empty'),
												'user_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('empty'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_agenda'),
												'tab1_link'			=>	$this->config->item('activity'),
												'tab1_active'		=>	$this->config->item('empty'),
                                                'tab2'				=>	$new_target,
												'tab2_link'			=>	$new_target_link,
												'tab2_active'		=>	$new_target_active,
                                                'tab3'				=>	$list_target,
                                                'tab3_link'			=>	$list_target_link,
												'tab3_active'		=>	$list_target_active,
                                                'tab4'				=>	'',
												'tab4_link'			=>	$new_target_link,
												'tab4_active'		=>	$new_target_active,
                                                'tab5'				=>	$this->lang->line('actv_daily'),
                                                'tab5_link'			=>	$this->config->item('actv_daily'),
												'tab5_active'		=>	$this->config->item('empty'),
												'tab6'				=>	"",
                                                'tab6_link'			=>	"",
												'tab6_active'		=>	$this->config->item('empty'),
												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                'tab7_link'			=>	$this->config->item('actv_monthly'),
												'tab7_active'		=>	$this->config->item('empty'),
												'tab8'				=>	$adv_search,
                                                'tab8_link'			=>	$adv_search_link,
												'tab8_active'		=>	$adv_search_active,
											 )				
					 );
		$this->load->vars($data);
		$this->load->theme('default');
       else:
            redirect($this->config->item('activity'));
       endif;    
	}
    
    function addtarget($user='',$group=''){
        if(($this->session->userdata('user_group')== $this->config->item('user') ) && ($this->session->userdata('user_pos')== $this->config->item('ta') )  ):
            $user=$this->session->userdata('user_id');
        else:
            $user="";
        endif;
        
        if($this->session->userdata('user_group')== $this->config->item('admin') ):
            $group=$this->config->item('user');
        endif;
        
        if($this->session->userdata('user_group')== $this->config->item('admin_dna') ):
            $group=$this->config->item('user_dna');
        endif;
        
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		*/
	    if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
         
        
            if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('admin_dna')) ):
                $add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('empty');
                
                $adv_search          = $this->lang->line('adv_search');
                $adv_search_link     = $this->config->item('actv_search');
                $adv_search_active   = $this->config->item('empty');
                
                $list_target 		 = $this->lang->line('actv_weekly');
                $list_target_link 	 = $this->config->item('actv_weekly');
                $list_target_active  = $this->config->item('empty');
                
                $new_target 		 = $this->lang->line('new_weekly');
                $new_target_link 	 = $this->config->item('new_target');
                $new_target_active   = $this->config->item('active');
            elseif(($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('se'))):
    			$add 		         = $this->lang->line('add');
                $add_link 	         = $this->config->item('actv_add');
                $add_active          = $this->config->item('empty');
                
                $list_target 		 = $this->lang->line('actv_weekly');
                $list_target_link 	 = $this->config->item('actv_weekly');
                $list_target_active  = $this->config->item('empty');
                
                $new_target 		 = $this->lang->line('new_weekly');
                $new_target_link 	 = $this->config->item('new_target');
                $new_target_active   = $this->config->item('active');
                
               	$adv_search          = "";
                $adv_search_link     = "";
                $adv_search_active   = "";    
            else:
                $add 		         = "";
                $add_link 	         = "";
                $add_active	         = "";
                
                $adv_search          = "";  
                $adv_search_link     = ""; 
                $adv_search_active   = "";
                
                $list_target 		 = "";
                $list_target_link 	 = "";
                $list_target_active  = "";
                
                $new_target 		 = "";
                $new_target_link 	 = "";
                $new_target_active   = "";
            endif;     
               
    		$data = array(
    						'title'		=>	$this->lang->line('new_weekly'),
    						'table'		=>	array(
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'products'			=>	$this->activities->getProducts(),
                                                    'customers'         =>  $this->activities->getCustomer(),
                                                    'details'           =>  $this->activities->getAllThisTarget(date('W'),date('Y'),$user,$group),
                                                    'nextdetails'       =>  $this->activities->getAllThisTarget(date('W')+1,date('Y'),$user,$group),
                                                    'actv'              =>  $this->activities->getAllThisTargetDetails(),        
                                                    'type'			    =>	$this->activities->getType(),
													'sales'				=>  $this->activities->getAllSalesFails(),
                                                    'value'             =>  "" ,
													'jobs'			    =>	$this->activities->getLastJob(),		
                                                    'weekly'            =>  $this->activities->getActivityWeek(date('W'),date('Y'),$user,$group)
    											 ),
                            'form'      =>  array('action'          =>  $this->config->item('actvtarget_save'),
                                                  'action_update'   =>  $this->config->item('actvtarget_update'),
                                                  'action2'         =>  $this->config->item('actvfailed_save')
                                                  ),                      
    						'content'	=> 	'form_target',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
    						'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$new_target,
    												'tab2_link'			=>	$new_target_link,
    												'tab2_active'		=>	$new_target_active,
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	'',
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	"",
                                                    'tab6_link'			=>	"",
    												'tab6_active'		=>	$this->config->item('empty'),
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$list_target,
                                                    'tab3_link'			=>	$list_target_link,
    												'tab3_active'		=>	$list_target_active,
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
    												'tab8_active'		=>	$adv_search_active,
    												'tab9'				=>	'',
                                                    'tab9_link'			=>	$this->config->item('edit_user'),
    												'tab9_active'		=>	$this->config->item('empty'),
    											 )			
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
       else:
            redirect($this->config->item('activity'));
       endif;       
	}
    
    function deleteactvtarget($id){
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;*/
		
        //if(($this->session->userdata('user_group')== $this->config->item('admin') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
            $this->activities->getTargetRemove($id);
            $this->session->set_flashdata('message','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_delete').'  </span>');
            redirect($this->input->server('HTTP_REFERER'));
        //else:
        //    redirect($this->config->item('activity'));
        //endif;      
    }
    
    function deletefailed($id){
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;*/
		
        //if(($this->session->userdata('user_group')== $this->config->item('admin') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
            $this->activities->getFailedRemove($id);
            $this->session->set_flashdata('message','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_delete').'  </span>');
            redirect($this->input->server('HTTP_REFERER'));
        //else:
        //    redirect($this->config->item('activity'));
        //endif;      
    }
    
    
    function saveactvtarget(){
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		*/
        if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
            if(($this->input->post('customer1')<>"") || ($this->input->post('customer2')<>"" ) ):
				//$val=count($this->activities->getTargetCek());
				$val=0;
                if($val<1):
					$this->activities->getTargetSave();
					$this->session->set_flashdata('message','<span class="message success"><strong>Success</strong>message - '.$this->lang->line('m_save').'  </span>');
					redirect($this->input->server('HTTP_REFERER'));
				else:
					$this->session->set_flashdata('message','<span class="message error"><strong>Error </strong>message - '.$this->lang->line('m_duplicate').'  </span>');
					redirect($this->input->server('HTTP_REFERER'));
				endif;
			else:
				$this->session->set_flashdata('message','<span class="message error"><strong>Empty</strong>Empty Customer Data </span>');
                redirect($this->input->server('HTTP_REFERER'));
			endif;
			
		else:
			redirect($this->config->item('activity'));
		endif; 
				 			
        
    }
    
    function saveactvfailed(){
	    /*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;
		*/
        if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
                if(($this->input->post('customer')=="") ):
			       $this->session->set_flashdata('message10','<span class="message error"><strong>Empty </strong>Empty Customer Data </span>');
                   redirect($this->input->server('HTTP_REFERER'));
			    endif;
			//if($this->input->post('save')):
                //$val=count($this->activities->getFailedCek());
                $val=0;
                if($val<1):
                    $this->activities->getFailedSave();
                    $this->session->set_flashdata('message10','<span class="message success"><strong>Success</strong>message - '.$this->lang->line('m_save').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                else:
                    $this->session->set_flashdata('message10','<span class="message error"><strong>Error </strong>message - '.$this->lang->line('m_duplicate').'  </span>');
                    redirect($this->input->server('HTTP_REFERER'));
                endif;
            //endif;    
        else:
            redirect($this->config->item('activity'));
        endif;      
    }
    
    function edittarget($id){
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;*/
		
	    if(($this->session->userdata('user_group')== $this->config->item('admin') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
         
        
            if(!$id){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }
               
    		$data = array(
    						'title'		=>	$this->lang->line('edit').' '.$id,
    						'table'		=>	array(
                                                    'value'				=>	$this->activities->getDataTarget($id),
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'customers'         =>  $this->activities->getCustomer(),
                                                    'type'			    =>	$this->activities->getType(),
    											 ),
                            'form'      =>  array('action'          =>  $this->config->item('actvtarget_save'),
                                                  'action_update'   =>  $this->config->item('actvtarget_update'),
                                                  'action2'         =>  $this->config->item('actvfailed_save')
                                                  ),                      
    						'content'	=> 	'form_target',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
                            'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$this->lang->line('add'),
    												'tab2_link'			=>	$this->config->item('actv_add'),
    												'tab2_active'		=>	$this->config->item('empty'),
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	$this->config->item('empty'),
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	$this->lang->line('actv_weekly'),
                                                    'tab6_link'			=>	$this->config->item('edit_user'),
    												'tab6_active'		=>	$this->config->item('empty'),
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('edit_user'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$this->lang->line('edittarget'),
                                                    'tab3_link'			=>	$this->config->item('actvtarget_edit').$id,
    												'tab3_active'		=>	$this->config->item('active'),
    												'tab8'				=>	'',
                                                    'tab8_link'			=>	'',
    												'tab8_active'		=>	$this->config->item('empty'),
    												'tab9'				=>	'',
                                                    'tab9_link'			=>	'',
    												'tab9_active'		=>	$this->config->item('empty'),
    											 )	                     		
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
        else:
            redirect($this->config->item('activity'));
        endif;     
	}
    
    function updatetarget(){
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;*/
		
        //if(($this->session->userdata('user_group')== $this->config->item('admin') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) || ($this->session->userdata('user_group')== $this->config->item('admin_dna') ) ||  ($this->session->userdata('user_group')== $this->config->item('co_admin') ) || ($this->session->userdata('user_pos')== $this->config->item('ta'))  || ($this->session->userdata('user_pos')== $this->config->item('se')) ):
         
        //if($this->input->post('save')){
                $this->activities->getTargetUpdate();
                $this->session->set_flashdata('message','<span class="message success"><strong>Succes </strong>message - '.$this->lang->line('m_update').'  </span>');                     
          //   }
                redirect($this->input->server('HTTP_REFERER')); 
        //else:
        //    redirect($this->config->item('activity'));
        //endif;   
    }
    
    function viewtarget($week,$year,$user){
        if(!$week){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }
        if(!$year){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }
        if(!$user){
                $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - '.$this->lang->line('m_wrong').'  </span>');    
                redirect($this->config->item('activity'));
            }          
		/*if ($this->session->userdata('user_group')== $this->config->item('user_dna')):
			  $this->session->set_flashdata('message','<span class="message error"><strong>Error</strong>message - Do Not Have Access</span>');    
              redirect($this->config->item('activity'));
		endif;*/
		
        if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('admin_dna')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))):
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('active');
            
            $new_target 		 = $this->lang->line('new_weekly');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active   = $this->config->item('empty');
            
           	$adv_search          = $this->lang->line('adv_search');
            $adv_search_link     = $this->config->item('actv_search');
            $adv_search_active   = $this->config->item('empty');
        elseif(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))):    
            $add 		         = $this->lang->line('add');
            $add_link 	         = $this->config->item('actv_add');
            $add_active          = $this->config->item('empty');
            
            $list_target 		 = $this->lang->line('actv_weekly');
            $list_target_link 	 = $this->config->item('actv_weekly');
            $list_target_active  = $this->config->item('active');
            
            $new_target 		 = $this->lang->line('new_weekly');
            $new_target_link 	 = $this->config->item('new_target');
            $new_target_active   = $this->config->item('empty');
            
           	$adv_search          = "";
            $adv_search_link     = "";
            $adv_search_active   = "";
        else:
            $add 		         = "";
            $add_link 	         = "";
            $add_active	         = "";
        
            $list_target 		 = "";
            $list_target_link 	 = "";
            $list_target_active  = "";
            
            $new_target 		 = "";
            $new_target_link 	 = "";
            $new_target_active   = "";  
			
            $adv_search          = "";
            $adv_search_link     = ""; 
            $adv_search_active   = "";
        endif;    
               
    		$data = array(
    						'title'		=>	$this->lang->line('view'),
    						'table'		=>	array(
                                                    'details'           =>  $this->activities->getAllThisTarget($week,$year,$user),
                                                    'nextdetails'       =>  $this->activities->getAllThisTarget($week+1,$year,$user),
                                                    'activity'			=>	$this->activities->getAll(),
                                                    'actv'              =>  $this->activities->getAllDataTargetDetails($week,$year,$user), 
                                                    'customers'         =>  $this->activities->getCustomer($user),
                                                    'type'			    =>	$this->activities->getType(),
                                                    'value'             =>  "" ,
                                                    'sales'				=>  $this->activities->getAllSalesFails(),
                                                    'products'			=>	$this->activities->getProducts(),
                                                    'pic'               =>  $user,
                                                    'weekly'            =>  $this->activities->getActivityWeek($week,$year,$user)
    											 ),
                            /*'form'      =>  array(
                                                    'action'            =>  $this->config->item('actvtarget_update'),
                                                    'action_update'     =>  $this->config->item('actvtarget_update')
                                                 ),     */
                            'form'      =>  array ('action'             =>  $this->config->item('actvtarget_save'),
                                                   'action_update'      =>  $this->config->item('actvtarget_update'),
                                                   'action2'            =>  $this->config->item('actvfailed_save')
                                                  ),                                       
    						'content'	=> 	'view_target',
    						'menu' 		=> 	array(
    												'dashboard_active'	=>	$this->config->item('empty'),
    												'contact_active'	=>	$this->config->item('empty'),
                                                    'contactdna_active'	=>	$this->config->item('empty'),
    												'activity_active'	=>	$this->config->item('active'),
    												'job_active'		=>	$this->config->item('empty'),
    												'call_active'		=>	$this->config->item('empty'),
    												'user_active'		=>	$this->config->item('empty'),
    												'report_active'		=>	$this->config->item('empty'),
    												'master_active'		=>	$this->config->item('empty'),
    												'graphic_active'	=>	$this->config->item('empty'),
    												'setting_active'	=>	$this->config->item('empty'),
    											 ),
                            'tab'		=>	array(
    												'tab1'				=>	$this->lang->line('my_agenda'),
    												'tab1_link'			=>	$this->config->item('activity'),
    												'tab1_active'		=>	$this->config->item('empty'),
                                                    'tab2'				=>	$this->lang->line('add'),
    												'tab2_link'			=>	$this->config->item('actv_add'),
    												'tab2_active'		=>	$this->config->item('empty'),
                                                    'tab4'				=>	'',
    												'tab4_link'			=>	'',
    												'tab4_active'		=>	$this->config->item('empty'),
                                                    'tab5'				=>	$this->lang->line('actv_daily'),
                                                    'tab5_link'			=>	$this->config->item('actv_daily'),
    												'tab5_active'		=>	$this->config->item('empty'),
    												'tab6'				=>	$this->lang->line('actv_weekly'),
                                                    'tab6_link'			=>	$this->config->item('actv_weekly'),
    												'tab6_active'		=>	$this->config->item('empty'),
    												'tab7'				=>	$this->lang->line('actv_monthly'),
                                                    'tab7_link'			=>	$this->config->item('actv_monthly'),
    												'tab7_active'		=>	$this->config->item('empty'),
    												'tab3'				=>	$this->lang->line('view_target'),
                                                    'tab3_link'			=>	$this->config->item('actvtarget_view').$week.'/'.$year,
    												'tab3_active'		=>	$this->config->item('active'),
    												'tab8'				=>	$adv_search,
                                                    'tab8_link'			=>	$adv_search_link,
								                    'tab8_active'		=>	$adv_search_active,
    												'tab9'				=>	'',
                                                    'tab9_link'			=>	'',
    												'tab9_active'		=>	$this->config->item('empty'),
    											 )	                     		
    					 );
    		$this->load->vars($data);
    		$this->load->theme('default');
    } 

}

/* End of file dashboard.php */
/* Location: ./system/application/modules/matchbox/controllers/dashboard.php */